WIDTH = 250
HEIGHT = 250
rc_list = []
unit = 50
class MyRect:
    def __init__(self, mid_x, mid_y, clr):
        self.mid_x = mid_x
        self.mid_y = mid_y
        self.clr = clr

    def GetGridPos(self):
        gx = self.mid_x // unit 
        gy = self.mid_y // unit
        return gx, gy

    def Draw(self,clr):
        rc = Rect((self.mid_x - unit // 2, self.mid_y - unit // 2), (unit, unit))
        screen.draw.filled_rect(rc, clr)
    
def draw():
    print("draw---used!")
    clr_list = testSnake()
    for it in range(0,len(rc_list)):
        rc_list[it].Draw(clr_list[it])

def genMatrix(rows,cols):
    print("genMatrix---used!")
    matrix = [[0 for col in range(cols)] for row in range(rows)]  
    for i in range(rows):  
        for j in range(cols):  
            matrix[i][j]
    return matrix
def testSnake():
    print("testSnake---used!")
    global rc_list
    clr_list = []
    number = 5
    matrix = genMatrix(number, number)
    i = 0
    j = 0
    total = matrix[i][j] = 1
    while(total < number * number):
        while(j + 1 < number and matrix[i][j + 1] == 0): 
            total += 1
            j += 1
            matrix[i][j] = total
        while(i + 1 < number and matrix[i + 1][j] == 0):
            total += 1
            i += 1
            matrix[i][j] = total
        while(j > 0 and matrix[i][j - 1] == 0): 
            total += 1
            j -= 1
            matrix[i][j] = total
        while(i + 1 > 0 and matrix[i - 1][j] == 0): 
            total += 1
            i -= 1
            matrix[i][j] = total
    for i in range(number):  
            for j in range(number):
                value = matrix[i][j]
                rv = value * 10
                clr = (rv,0,0)
                clr_list.append(clr)
                rc = MyRect(i * unit + unit // 2, j * unit + unit // 2, clr)
                rc_list.append(rc)
    return clr_list
